/*
 * @lc app=leetcode.cn id=1725 lang=typescript
 *
 * [1725] 可以形成最大正方形的矩形数目
 */

// @lc code=start
function countGoodRectangles(rectangles: number[][]): number {
    const rects = rectangles.map((i) => {
        return Math.min(...i);
    });
    let max = 0;
    let count = 0;
    for (let i = 0; i < rects.length; i++) {
        const element = rects[i];
        if (element > max) {
            max = element;
            count = 0;
        }
        if (element === max) {
            count++;
        }
    }
    return count;
}
// @lc code=end
